package com.vpen.account.demo.model.enums;

import cn.hutool.core.util.EnumUtil;
import com.fasterxml.jackson.annotation.JsonValue;
import com.vpen.account.demo.utils.SpringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 描述
 *
 * @author 韦鹏
 * @date 2022/8/15 17:27
 */
@Getter
@AllArgsConstructor
public enum LoginType {

    /**
     * 用户名的登录
     */
    USERNAME(0, "username"),
    /**
     * 手机号登录
     */
    PHONE(1, "phone");


    @JsonValue
    private final Integer index;

    @JsonValue
    private final String value;


    /**
     * 登录类型
     */
    private final static String TYPE = "type";

    /**
     * 获取当前登录类型
     *
     * @return com.vpen.account.demo.model.enums.LoginType
     * @author 韦鹏
     * @date 2022/8/15 17:50
     **/
    public static LoginType getType() {
        return EnumUtil.likeValueOf(LoginType.class, SpringUtils.getParameter(TYPE));
    }

}
